﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.Text;

namespace zEngine
{
    public class FileIO
    {
        /// <summary>
        /// Save an object to XML file
        /// </summary>
        public static void SaveSerializeToXML(object serializedObject, string XMLPath)
        {
            //Stream stream = File.Create(XMLPath);
            //XmlSerializer serializer = new XmlSerializer(serializedObject.GetType());
            //serializer.Serialize(stream, serializedObject);
            //stream.Close();
        }

        /// <summary>
        /// Load an object from XML File
        /// </summary>
        public static object LoadSerializeFromXML(string XMLPath, Type T)
        {
            if (File.Exists(XMLPath))
            {
                FileStream saveFile = File.Open(XMLPath, FileMode.Open);
                XmlSerializer serializer = new XmlSerializer(T);
                object result = serializer.Deserialize(saveFile);
                saveFile.Close();
                return result;
            }
            else
            {
                return null;
            }
        }


    }
}
